package com.bwie.doctor.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.doctor.service.RegisteredService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/registered")
public class RegisteredController {
    @Autowired
    private RegisteredService registeredService;

    /**
     * 挂号
     * @return
     */
    @PostMapping("/register/{dockerName}/{patientName}")
    public Result register(@PathVariable String dockerName,@PathVariable String patientName){
        registeredService.register(dockerName,patientName);
        return Result.success();
    }

    /**
     * 取消挂号
     * @param dockerName
     * @param patientName
     * @return
     */
    @DeleteMapping("/cancelRegister/{dockerName}/{patientName}")
    public Result cancelRegister(@PathVariable String dockerName,@PathVariable String patientName){
        registeredService.cancelRegister(dockerName,patientName);
        return Result.success();
    }

    /**
     * 查询挂号状态
     * @param dockerName
     * @param patientName
     * @return
     */
    @GetMapping("/getRegisterState")
    public Integer getRegisterState(@RequestParam String dockerName,@RequestParam String patientName){
        return registeredService.getRegisterState(dockerName,patientName);
    }

    /**
     * 根据患者姓名查询挂号记录
     * @param
     * @param patientName
     * @return
     */
    @GetMapping("/getRegisterByPatientName/{patientName}")
    public Integer getRegisterByPatientName(@PathVariable String patientName){
        return registeredService.getRegisterByPatientName(patientName);
    }
}
